/*
 * @lc app=leetcode.cn id=1 lang=swift
 *
 * [1] 两数之和
 */

// @lc code=start
class Solution {
    func twoSum(_ nums: [Int], _ target: Int) -> [Int] {
        var numDict: [Int: Int] = [:]
        for i in 0..<nums.count {
            let res = target - nums[i]
            if let j = numDict[res] {
                return [j, i]
            } else {
                numDict[nums[i]] = i
            }
        }
        return []
    }
}
// @lc code=end

